//-----------------------------------------------------------------------
// <copyright file="MailLetterService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class MailLetterService
    {
        #region MailLetter

        public static void CreateMailLetter(MailLetter mailLetter)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                mailLetterDAO.CreateMailLetter(mailLetter);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateMailLetterException, ex);
            }
        }        

        public static void UpdateMailLetter(MailLetter mailLetter)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                mailLetterDAO.UpdateMailLetter(mailLetter);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateMailLetterException, ex);
            }
        }        

        public static void DeleteMailLetter(long mailLetterId)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                mailLetterDAO.DeleteMailLetter(mailLetterId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteMailLetterException, ex);
            }
        }
        
        public static MailLetter GetMailLetter(long mailLetterId)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                return mailLetterDAO.GetMailLetter(mailLetterId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMailLetterException, ex);
            }
        }                

        public static MailLetterCollection GetMailLetterList(MailLetterColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                return mailLetterDAO.GetMailLetterList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMailLetterListException, ex);
            }
        }        

        public static MailLetterCollection GetMailLetterList(MailLetterColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                return mailLetterDAO.GetMailLetterList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMailLetterListException, ex);
            }
        }        

	    public static MailLetterCollection GetMailLetterListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                return mailLetterDAO.GetMailLetterListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMailLetterListException, ex);
            }
        }        

        public static MailLetterCollection GetMailLetterListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                MailLetterDAO mailLetterDAO = new MailLetterDAO();
                return mailLetterDAO.GetMailLetterListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMailLetterListException, ex);
            }
        }        

        #endregion
    }
}